package com.jtjrenren.android.taxi.driver.core.order.details;

import com.jtjrenren.android.taxi.driver.bean.Order;
import com.jtjrenren.android.taxi.driver.bean.event.OrderDetailsEvent;

import com.jtjrenren.android.taxi.driver.bean.api.ApiOrderCost;
import com.jtjrenren.android.taxi.driver.bean.event.OrderCostEvent;
import com.jtjrenren.android.taxi.driver.manger.api.ApiWorks;
import com.library.utils.LogUtil;

import org.greenrobot.eventbus.EventBus;

/**
 * Created by Administrator on 2016/8/29.
 */

public class OrderDetailsInteractorImpl implements OrderDetailsInteractor {

    @Override
    public void getOrderCost(String orderID) {
        LogUtil.log("order","刷新订单费用信息---数据");
        ApiWorks.getOrderCost(orderID, new ApiWorks.ResponseListener<ApiOrderCost>() {
            @Override
            public void onResponse(ApiOrderCost apiOrderCost) {
                LogUtil.log("order","刷新订单费用信息---数据结果");
                if (apiOrderCost != null && apiOrderCost.getDataList() != null && apiOrderCost.getDataList().size() > 0) {
                    EventBus.getDefault().post(new OrderCostEvent(apiOrderCost.getDataList().get(0)));
                }
            }
        });
    }

    @Override
    public void getOrderDetails(String orderID) {
        LogUtil.log("applog","获取订单详情----开始");
        ApiWorks.getOrderDetails(orderID, new ApiWorks.ResponseListener<Order>() {
            @Override
            public void onResponse(Order order) {
                LogUtil.log("applog","获取订单详情----结果");
                EventBus.getDefault().post(new OrderDetailsEvent(order));
            }
        });
    }
}
